// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.spnetwork;

import java.util.ArrayDeque;

public final class ZomboidNetDataPool {
    public static ZomboidNetDataPool instance = new ZomboidNetDataPool();
    private final ArrayDeque<ZomboidNetData> Pool = new ArrayDeque();

    public ZomboidNetData get() {
        synchronized (this.Pool) {
            return this.Pool.isEmpty() ? new ZomboidNetData() : (ZomboidNetData)this.Pool.pop();
        }
    }

    public void discard(ZomboidNetData data) {
        data.reset();
        if (data.buffer.capacity() == 2048) {
            synchronized (this.Pool) {
                this.Pool.add(data);
            }
        }
    }

    public ZomboidNetData getLong(int len) {
        return new ZomboidNetData(len);
    }
}
